/*
* TFModelInterface.h
*
* This class stores the whole Troops & Flags game state.
* 
* Author: Rapid Dojo
* Date: Oct 19, 2007
*/

#ifndef TFModelInterface_H
#define TFModelInterface_H

#include "TFConstants.h"
#include "TFMenu.h"
#include "TFBoard.h"
#include <vector>
#include "TFRuleCheckerInterface.h"

using std::vector;
class TFRuleCheckerInterface;

class TFModelInterface
{
public:
	virtual TF_GAME_MODE GetGameMode(){return NO_MODE;}
	virtual void RandomSetup(TF_PLAYERS player){;}
	virtual void InitializeAll() {;}

	virtual void SetGameMode(TF_GAME_MODE newMode){;}

	virtual TFMenu * GetMenuModel(){return _menuModel;}

	/*
	* Needs access to the rules
	*/
	virtual void SetRuleChecker(TFRuleCheckerInterface * iTFRulechecker){_ruleChecker = iTFRulechecker;}


	virtual TFBoard * GetBoard() { return board; }
	virtual TF_PLAYERS GetTurn() { return playerTurn; }
	virtual TF_TURN_STATE GetTurnState() { return turnState; }
	virtual void SetTurn(TF_PLAYERS newTurn) { playerTurn = newTurn; }
	virtual void SetTurnState(TF_TURN_STATE newState) { turnState = newState; }
	virtual TF_SELECTION GetSelected() { return isSelected; }
	virtual void SetSelected(TF_SELECTION mySelection) { isSelected = mySelection; }
	virtual int GetActionPoints() { return actionPoints; }
	virtual void SetActionPoints(int points) { actionPoints = points; }
	virtual TFGameMove* GetGameMove() { return move; }
	virtual TFGameTurn* GetGameTurn() { return turn; }

	virtual void RandomPlaceBarricade(TF_PLAYERS player){};
	virtual void RandomPlaceFlagBarricade(TF_PLAYERS player){};

	virtual int  PiecesToPlace(){return 0;};
	virtual bool  CanPlacePiece(TF_PIECE_STATE piece){return false;};
	virtual void AddPieceToPlace(TFGamePiece* piece){};
	virtual void NewGame(){};
	virtual void PiecePlaced(TF_PIECE_STATE piece){};
	virtual bool DoInitSetup() { return initSetup; }
	virtual void DoneSetup() { initSetup = false; };
	virtual bool CanAddTroop(int color) { return ((color==0)?canAddTroopRed:canAddTroopBlue); }
	virtual void TakeTroop(bool takeTroop, int color) { if (color==0) { canAddTroopRed = takeTroop; } 
														else { canAddTroopBlue = takeTroop; }}
	virtual int GetNumTroops() { return numTroops; }
	virtual int GetNumFlags() { return numFlags; }
	virtual int GetNumBarricades() { return numBarricades; }
	virtual void SetNumTroops(int num) { numTroops = num; }
	virtual void SetNumFlags(int num) { numFlags = num; }
	virtual void SetNumBarricades(int num) { numBarricades = num; }

	virtual HRESULT RoomForBarricade() {return S_OK;}

	virtual HRESULT CanFortifyFlag() {return S_OK;}

	virtual HRESULT RoomForTroop() {return S_OK;}
	
	vector<TFGamePiece*> pieces_to_place;

	virtual ~ TFModelInterface(){}

protected:
	TF_GAME_MODE gameMode;
	TFMenu * _menuModel;
	TFBoard* board;
	TF_PLAYERS playerTurn;
	TF_TURN_STATE turnState;
	TF_SELECTION isSelected;
	int actionPoints;
	TFGameMove* move;
	TFGameTurn* turn;	
	bool initSetup;
	bool canAddTroopRed;
	bool canAddTroopBlue;
	int numTroops;
	int numFlags;
	int numBarricades;

	TFRuleCheckerInterface * _ruleChecker;	
};

#endif
